-<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.soft.model.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
 .row ul {
 	text-align: left;
    margin-left: 100px;
 }
 .row li{ 
 	list-style-type:none;   
 	display:inline; 
 } 
 
 h3 label{
     display: block;
 }


</style>
</head>
<link rel="stylesheet" href="../../css/common.css" />
<script type="text/javascript">
$(function(){
	$(":checkbox").click(function(){
			var pid = $(this).attr("pid");
			if(pid == 0){
				var id = $(this).attr("id");
				
				if($(this).prop('checked')){
					$("input[pid='"+id+"']").prop("checked",true);
				}else{
					$("input[pid='"+id+"']").prop("checked",false);
				}
				return;
			}
			var count = $("input[pid='"+pid+"']:checked").length;
			if(count == 0){
				$("#"+pid).prop("checked",false);
			}else{
				$("#"+pid).prop("checked",true);
			}
			
	});
	
	$("#save").click(function(){
		var ids = "";
		$(":checked").each(function(){
			ids += $(this).val() + ",";
		});
		$("#ids").val(ids);
// 		alert(ids);
		$("#theForm").submit();
	});
	
})
	
</script>
		<div class="title-area bg-color-black font-normal font-white">乌托邦别墅预定管理平台>系统设置>用户授权</div>
	<!-- user_detail -->
	<form action="user_permissionDoAdd" id="theForm" method="post">
		<input type="hidden" name="userId" value="${userId }">
		<input type="hidden" name="ids" id="ids" value="">
		<div class="edit-area">
			<div class="container">
				<div class="row">
					<div class="title"></div>
				</div>
				<div class="row">
					<div class="label must">账户</div>
					<label class="edit">${username }</label>
				</div>
				<div class="row">
					<div class="title must">授权</div>
				</div>
				
				<% 	//所有权限
					List<Permission> list_p = (List<Permission>)request.getAttribute("list_p"); 
					//用户的权限
					Map<Integer,Object> upMap = (Map<Integer,Object>)request.getAttribute("upMap");
				%>
					
				<% if(list_p != null && list_p.size() > 0){
				   		for(Permission permission : list_p){
				%>
				<div class="row">
					<h3>
						<label style="display: block;"><div class="check-item">
						<%
						if(upMap.containsKey(permission.getId())){ %>
							<input id="s_<%=permission.getId()%>" type="checkbox" checked="checked" pid="<%=permission.getParentId()%>" value="<%=permission.getId()%>">
						<%}else{%>
							<input id="s_<%=permission.getId()%>" type="checkbox" pid="<%=permission.getParentId()%>" value="<%=permission.getId()%>">
						<%}%>
						<label for="s_<%=permission.getId() %>"><%=permission.getPermissionName() %></label></div></label>
       				</h3>
       				<ul class="spec_sports" id="rg_1">
       				<%  for(Permission pChild : permission.getList_permission()){ %>
	       				<li>
	       					<span class="span1"><div class="check-item">
	       					 <%=pChild.getId() %>
	       					<%if(upMap.containsKey(pChild.getId())){ %>
	       						<input id="s_<%=pChild.getId() %>" pid="s_<%=permission.getId() %>" checked="checked" type="checkbox" value="<%=pChild.getId() %>">
	       					<%}else{ %>
	       						<input id="s_<%=pChild.getId() %>" pid="s_<%=permission.getId() %>" type="checkbox" value="<%=pChild.getId() %>">
	       					<%} %>
	       					<label for="s_<%=pChild.getId() %>"><%=pChild.getPermissionName() %></label></div>
							</span>
		    			</li>
		    		<%} %>
       				</ul>
				</div>
				<% }
				}%>
<!-- 				<div class="row"> -->
<!-- 					<h3> -->
<!-- 						<label style="display: block;"><div class="check-item"><input id="s_1" type="checkbox" pid="0"><label for="s_1">系统管理</label></div></label> -->
<!--        				</h3> -->
<!--        				<ul class="spec_sports" id="rg_1"> -->
<!-- 	       				<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_2" pid="s_1" type="checkbox"><label for="s_2">用户管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_3" pid="s_1" type="checkbox"><label for="s_3">角色管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_4" pid="s_1" type="checkbox"><label for="s_4">用户管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_5" pid="s_1" type="checkbox"><label for="s_5">角色管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_6" pid="s_1" type="checkbox"><label for="s_6">用户管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_7" pid="s_1" type="checkbox"><label for="s_7">角色管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!--        				</ul> -->
<!-- 				</div> -->
<!-- 				<div class="row"> -->
<!-- 					<h3> -->
<!-- 						<label style="display: block;"><div class="check-item"><input id="s_8" pid="0" type="checkbox"><label for="s_8">内容管理</label></div></label> -->
<!--        				</h3> -->
<!--        				<ul class="spec_sports" id="rg_1"> -->
<!-- 	       				<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_9" pid="s_8" type="checkbox"><label for="s_9">城市管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_10" pid="s_8" type="checkbox"><label for="s_10">店面管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_11" pid="s_8" type="checkbox"><label for="s_11">时段管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!-- 		    			<li> -->
<!-- 	       					<span class="span1"><div class="check-item"><input id="s_12" pid="s_8" type="checkbox"><label for="s_12">别墅管理</label></div> -->
<!-- 							</span> -->
<!-- 		    			</li> -->
<!--        				</ul> -->
<!-- 				</div> -->
				
				<div class="row">
<!-- 					<button id="cancel" class="font-white button-del font-normal">取消</button> -->
					<button id="save" class="font-white button-put font-normal">保存</button>
				</div>
				
			</div>
		</div>
		</form>
		
</html>